package com.hikw.controller;

import com.hikw.utils.EmailUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description: 邮件控制器
 * @ClassNmae: EmailController
 * @Author: 何同学
 * @DateTime: 2022-02-26 15:05
 **/
@RestController
public class EmailController {

    @Autowired
    private EmailUtils emailUtils;

    @PostMapping("/sendSimpleMail")
    public String sendSimpleMail(
            @RequestParam String to,
            @RequestParam String subject,
            @RequestParam String content) {
        return emailUtils.sendSimpleMail(to, subject, content);
    }

    @PostMapping("/sendAttachmentMail")
    public String sendAttachmentMail(
            @RequestParam String to,
            @RequestParam String subject,
            @RequestParam String content,
            @RequestPart MultipartFile attachment) {
        return emailUtils.sendAttachmentMail(to, subject, content, attachment);
    }


}
